package com.linsen.core.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@Getter
@AllArgsConstructor
public enum EnvType {
    LOCAL("local", "本地环境"),
    DEV("dev", "开发环境"),
    TEST("test", "测试环境"),
    PROD("prod", "生产环境");

    @JsonValue
    private String value;
    private String description;

    private static final Map<String, EnvType> VALUES = new HashMap<>();

    static {
        for (final EnvType envType : EnvType.values()) {
            EnvType.VALUES.put(envType.getValue(), envType);
        }
    }

    @JsonCreator
    public static EnvType getByValue(String value) {
        return EnvType.VALUES.get(value);
    }
}
